﻿using AutoMapper;
using IOA.MES.Common;
using IOA.MES.DataAccess.Entity;
using IOA.MES.DataAccess.Enum;
using IOA.MES.DataAccess.VModel;
using IOA.MES.Log.Business;
using IOA.MES.Log.DataAccess.VModel;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IOA.MES.Business
{
    /// <summary>
    /// 分档规则管理（错误代码：135001）
    /// </summary>
    public class BinningSchemeMgr
    {
        private MESContext mesDb = new MESContext("MES");

        /// <summary>
        /// 编辑分档规则
        /// </summary>
        /// <param name="model">分档规则对象</param>
        public void EditSchema(VBinningSchema model)
        {
            model.WorkshopName = new WorkshopMgr().GetWorkshop(model.WorkshopCode)?.WorkshopName;
            if (model.PkId <= 0)
            {
                var exist = mesDb.BinningSchemas.FirstOrDefault(_ => _.WorkshopCode == model.WorkshopCode && _.SchemaName == model.SchemaName && _.Valid);
                if (exist != null)
                {
                    throw new MultiLanBizException(135001);//分档规则已存在，请更换名称
                }
                var entity = Mapper.Map<BinningSchema>(model);
                entity.Status = CommonStatus.Normal;
                entity.CreateTime = DateTime.Now;
                mesDb.BinningSchemas.Add(entity);
                mesDb.SaveChanges();
            }
            else
            {
                var exist = mesDb.BinningSchemas.FirstOrDefault(_ => _.PkId != model.PkId && _.WorkshopCode == model.WorkshopCode && _.SchemaName == model.SchemaName && _.Valid);
                if (exist != null)
                {
                    throw new MultiLanBizException(135001);//分档规则已存在，请更换名称
                }
                var entity = mesDb.BinningSchemas.FirstOrDefault(_ => _.PkId == model.PkId && _.Valid);
                if (entity == null)
                {
                    throw new MultiLanBizException(135002);//分档规则不存在
                }
                //var workOrderSchemas = mesDb.WorkOrderBinningSchemas.FirstOrDefault(_ => _.BinningSchemeId == model.PkId && _.Valid);
                //if (workOrderSchemas != null)
                //{
                //    throw new MultiLanBizException(135003);//分档规则已在工单使用，无法编辑
                //}

                mesDb.BinningSchemas.Attach(entity);
                entity.WorkshopCode = model.WorkshopCode;
                entity.WorkshopName = model.WorkshopName;
                entity.SchemaName = model.SchemaName;
                entity.ModifyBy = model.ModifyBy;
                entity.ModifyTime = DateTime.Now;
                mesDb.SaveChanges();
            }
        }

        /// <summary>
        /// 查询所有铭牌方案
        /// </summary>
        /// <param name="workshopCode">车间代码</param>
        /// <returns>铭牌方案列表</returns>
        public List<VBinningPower> QueryNameplateModels(string workshopCode)
        {
            var entities = (from power in mesDb.BinningPowers.AsNoTracking()
                            join schema in mesDb.BinningSchemas.AsNoTracking() on power.SchemaId equals schema.PkId
                            where schema.WorkshopCode == workshopCode && power.Valid && schema.Valid
                            select new VBinningPower
                            {
                                PkId = power.PkId,
                                CreateBy = power.CreateBy,
                                SchemaName = schema.SchemaName,
                                CreateTime = power.CreateTime,
                                FF = power.FF,
                                Impp = power.Impp,
                                Isc = power.Isc,
                                ModifyBy = power.ModifyBy,
                                ModifyTime = power.ModifyTime,
                                NameplateModel = power.NameplateModel,
                                Pmax = power.Pmax,
                                Power = power.Power,
                                PowerMax = power.PowerMax,
                                PowerMin = power.PowerMin,
                                SchemaId = power.SchemaId,
                                Valid = power.Valid,
                                Vmpp = power.Vmpp,
                                Voc = power.Voc
                            }).OrderByDescending(_ => _.PkId).ToList();
            return entities;
        }

        /// <summary>
        /// 查询所有铭牌方案
        /// </summary>
        /// <param name="workshopCode">车间代码</param>
        /// <returns>铭牌方案列表</returns>
        public List<VBinningSchema> QueryAllSchemas(List<string> workshopCodes)
        {
            workshopCodes = workshopCodes.Where(_ => !string.IsNullOrWhiteSpace(_)).Select(_ => _.Trim().ToUpper().Trim()).Distinct().ToList();
            if (!workshopCodes.Any())
            {
                return new List<VBinningSchema>();
            }
            var schemas = mesDb.BinningSchemas.AsNoTracking().Where(_ => workshopCodes.Contains(_.WorkshopCode) && _.Valid).ToList();
            var schemaIds = schemas.Select(_ => _.PkId).ToList();
            var powers = !schemaIds.Any() ? new List<BinningPower>()
                : mesDb.BinningPowers.AsNoTracking().Where(_ => schemaIds.Contains(_.SchemaId) && _.Valid).ToList();
            var powerIds = powers.Select(_ => _.PkId).ToList();
            var currents = !powerIds.Any() ? new List<BinningCurrent>()
                : mesDb.BinningCurrents.AsNoTracking().Where(_ => powerIds.Contains(_.PowerId) && _.Valid).ToList();

            var result = Mapper.Map<List<VBinningSchema>>(schemas).OrderBy(_ => _.SchemaName).ToList();
            result.ForEach(schema =>
            {
                schema.BinningPowers = Mapper.Map<List<VBinningPower>>(powers.Where(_ => _.SchemaId == schema.PkId).ToList()).OrderBy(_ => _.Power).ToList();
                schema.BinningPowers.ForEach(power =>
                {
                    power.Currents = Mapper.Map<List<VBinningCurrent>>(currents.Where(_ => _.PowerId == power.PkId).ToList()).OrderBy(_ => _.CurrentMin).ToList();
                });
            });

            return result;
        }

        /// <summary>
        /// 查询分档规则列表
        /// </summary>
        /// <param name="page">页面所用</param>
        /// <param name="limit">页面容量</param>
        /// <param name="total">全部数量</param>
        /// <param name="workshopCode">车间代码</param>
        /// <param name="key">规则名称</param>
        /// <returns>规则列表</returns>
        public List<VBinningSchema> Query(int page, int limit, out int total, string workshopCode, string key)
        {
            var query = mesDb.BinningSchemas.Where(_ => _.WorkshopCode == workshopCode && _.Valid);
            if (!string.IsNullOrWhiteSpace(key))
            {
                query = query.Where(_ => _.SchemaName.Contains(key));
            }

            total = query.Count();
            query = query.OrderByDescending(_ => _.PkId);
            var entities = limit <= 0 ? query.ToList() : query.Skip((page - 1) * limit).Take(limit).ToList();
            var models = Mapper.Map<List<VBinningSchema>>(entities);
            var schemaIds = models.Select(_ => _.PkId).Distinct().ToList();
            var powers = !schemaIds.Any() ? new List<BinningPower>() : mesDb.BinningPowers.Where(_ => schemaIds.Contains(_.SchemaId) && _.Valid).ToList();
            models.ForEach(schema =>
            {
                schema.BinningPowers = Mapper.Map<List<VBinningPower>>(powers.Where(_ => _.SchemaId == schema.PkId).ToList());
            });

            return models;
        }

        /// <summary>
        /// 查询工单分档规则
        /// </summary>
        /// <param name="workOrderNo">工单号</param>
        /// <returns>分档规则</returns>
        public VBinningSchema GeBinningSchema(string workOrderNo)
        {
            var workOrderSchema = mesDb.WorkOrderBinningSchemas.FirstOrDefault(_ => _.WorkOrderNo == workOrderNo && _.Valid);
            if (workOrderSchema == null)
            {
                return null;
            }
            var schema = mesDb.BinningSchemas.FirstOrDefault(_ => _.PkId == workOrderSchema.BinningSchemeId && _.Valid);
            if (schema == null)
            {
                return null;
            }
            var powers = mesDb.BinningPowers.Where(_ => _.SchemaId == schema.PkId && _.Valid).OrderBy(_ => _.Power).ToList();
            var currents = mesDb.BinningCurrents.Where(_ => _.SchemaId == schema.PkId && _.Valid).OrderBy(_ => _.CurrentMin).ToList();

            var model = Mapper.Map<VBinningSchema>(schema);
            model.BinningPowers = Mapper.Map<List<VBinningPower>>(powers);
            model.BinningPowers.ForEach(power =>
            {
                power.Currents = Mapper.Map<List<VBinningCurrent>>(currents.Where(_ => _.PowerId == power.PkId).ToList());
            });

            return model;
        }

        /// <summary>
        /// 查询工单铭牌方案
        /// </summary>
        /// <param name="workOrderNo">工单号</param>
        /// <returns>名牌方案列表</returns>
        public List<VBinningPower> QueryWorkOrderBinningPowers(string workOrderNo)
        {
            var workOrderPowerIds = mesDb.WorkOrderBinningSchemas.AsNoTracking().Where(_ => _.WorkOrderNo == workOrderNo && _.Valid).Select(_ => _.BinningPowerId).ToList();
            var binningPowers = Mapper.Map<List<VBinningPower>>(mesDb.BinningPowers.AsNoTracking().Where(_ => workOrderPowerIds.Contains(_.PkId) && _.Valid).ToList());
            var powerIds = binningPowers.Select(_ => _.PkId).Distinct().ToList();
            var currents = mesDb.BinningCurrents.AsNoTracking().Where(_ => powerIds.Contains(_.PowerId) && _.Valid).ToList();
            binningPowers.ForEach(power =>
            {
                power.Currents = Mapper.Map<List<VBinningCurrent>>(currents.Where(_ => _.PowerId == power.PkId));
            });
            return binningPowers;
        }

        /// <summary>
        /// 删除分档规则
        /// </summary>
        /// <param name="model">分档规则</param>
        public void Delete(VBinningSchema model)
        {
            var entity = mesDb.BinningSchemas.FirstOrDefault(_ => _.PkId == model.PkId && _.Valid);
            if (entity == null)
            {
                throw new MultiLanBizException(135002);//分档规则不存在
            }
            var workOrderSchemas = mesDb.WorkOrderBinningSchemas.Count(_ => _.BinningSchemeId == model.PkId && _.Valid);
            if (workOrderSchemas > 0)
            {
                throw new MultiLanBizException(135004);//分档规则已在工单使用，无法删除
            }

            mesDb.BinningSchemas.Attach(entity);
            entity.Valid = false;
            entity.ModifyBy = model.ModifyBy;
            entity.ModifyTime = DateTime.Now;

            var powers = mesDb.BinningPowers.AsNoTracking().Where(_ => _.SchemaId == model.PkId && _.Valid).ToList();
            powers.ForEach(_ =>
            {
                mesDb.BinningPowers.Attach(_);
                _.Valid = false;
                _.ModifyBy = model.ModifyBy;
                _.ModifyTime = DateTime.Now;
            });
            var currents = mesDb.BinningCurrents.AsNoTracking().Where(_ => _.SchemaId == model.PkId && _.Valid).ToList();
            currents.ForEach(_ =>
            {
                mesDb.BinningCurrents.Attach(_);
                _.Valid = false;
                _.ModifyBy = model.ModifyBy;
                _.ModifyTime = DateTime.Now;
            });

            mesDb.SaveChanges();
        }

        /// <summary>
        /// 获取分档规则
        /// </summary>
        /// <param name="schemaId">分档规则ID</param>
        /// <returns>分档规则对象</returns>
        public VBinningSchema GetBinningSchema(int schemaId)
        {
            var entity = mesDb.BinningSchemas.AsNoTracking().FirstOrDefault(_ => _.PkId == schemaId && _.Valid);
            return Mapper.Map<VBinningSchema>(entity);
        }

        /// <summary>
        /// 获取功率档对象
        /// </summary>
        /// <param name="powerId">功率档ID</param>
        /// <returns>功率档对象</returns>
        public VBinningPower GetBinningPower(int powerId)
        {
            var entity = mesDb.BinningPowers.AsNoTracking().FirstOrDefault(_ => _.PkId == powerId && _.Valid);
            if (entity == null)
            {
                return null;
            }
            var model = Mapper.Map<VBinningPower>(entity);
            var currents = mesDb.BinningCurrents.AsNoTracking().Where(_ => _.PowerId == powerId && _.Valid).ToList();
            model.Currents = Mapper.Map<List<VBinningCurrent>>(currents);
            return model;
        }

        /// <summary>
        /// 编辑功率档
        /// </summary>
        /// <param name="model">功率档</param>
        public void EditPower(VBinningPower model)
        {
            var eixstPowers = mesDb.BinningPowers.AsNoTracking().Where(_ => _.SchemaId == model.SchemaId && _.Valid).ToList();
            eixstPowers = model.PkId <= 0 ? eixstPowers : eixstPowers.Where(_ => _.PkId != model.PkId).ToList();
            if (eixstPowers.Any(_ => _.Power == model.Power))
            {
                throw new MultiLanBizException(135005);//该功率档已存在
            }
            else if (eixstPowers.Any(_ => model.PowerMin >= _.PowerMin && model.PowerMin < _.PowerMax
                                  || model.PowerMax > _.PowerMin && model.PowerMax < _.PowerMax
                                  || model.PowerMin < _.PowerMin && model.PowerMax >= _.PowerMax))
            {
                throw new MultiLanBizException(135006);//该功率判定范围跟现有功率档重合
            }

            if (model.PkId <= 0)
            {
                var existNameplateModel = mesDb.BinningPowers.AsNoTracking().FirstOrDefault(_ => _.SchemaId == model.SchemaId && _.NameplateModel == model.NameplateModel && _.Valid);
                if (existNameplateModel != null)
                {
                    throw new MultiLanBizException(135014);//铭牌型号已存在
                }
                var entity = Mapper.Map<BinningPower>(model);
                entity.CreateTime = DateTime.Now;
                mesDb.BinningPowers.Add(entity);
                mesDb.SaveChanges();

                new TaskFactory().StartNew(() =>
                {
                    var user = new UserMgr().GetUser(entity.CreateBy);
                    new OprLogMgr().AddLogs(new List<VOprLog> { new VOprLog
                    {
                        SubjectType = "功率档",
                        SubjectNo = entity.PkId.ToString(),
                        LogName = "添加功率档",
                        LogStatus = "正常",
                        OpeatorId = entity.CreateBy,
                        OpeatorName = user?.TrueName,
                        LogContent = $"添加功率档：{JsonConvert.SerializeObject(entity)}",
                        LogTime = DateTime.Now,
                        CreateBy = entity.CreateBy
                    }});
                });
            }
            else
            {
                var entity = mesDb.BinningPowers.FirstOrDefault(_ => _.PkId == model.PkId && _.Valid);
                if (entity == null)
                {
                    throw new MultiLanBizException(135007);//该功率档不存在
                }

                var oldPowerJson = JsonConvert.SerializeObject(entity);
                mesDb.BinningPowers.Attach(entity);
                entity.ModifyBy = model.ModifyBy;
                entity.ModifyTime = DateTime.Now;
                entity.NameplateModel = model.NameplateModel;
                entity.PowerMax = model.PowerMax;
                entity.PowerMin = model.PowerMin;
                entity.Pmax = model.Pmax;
                entity.Voc = model.Voc;
                entity.Isc = model.Isc;
                entity.Vmpp = model.Vmpp;
                entity.Impp = model.Impp;
                entity.FF = model.FF;
                mesDb.SaveChanges();

                new TaskFactory().StartNew(() =>
                {
                    var user = new UserMgr().GetUser(entity.ModifyBy);
                    new OprLogMgr().AddLogs(new List<VOprLog> { new VOprLog
                    {
                        SubjectType = "功率档",
                        SubjectNo = entity.PkId.ToString(),
                        LogName = "修改功率档",
                        LogStatus = "正常",
                        OpeatorId = entity.ModifyBy,
                        OpeatorName = user?.TrueName,
                        LogContent = $"修改功率档，原功率档：{oldPowerJson}，新功率档：{JsonConvert.SerializeObject(entity)}",
                        LogTime = DateTime.Now,
                        CreateBy = entity.ModifyBy
                    }});
                });
            }
        }

        /// <summary>
        /// 查询功率档列表
        /// </summary>
        /// <param name="schemaId">分档规则ID</param>
        /// <returns>功率档列表</returns>
        public List<VBinningPower> QueryBinningPowers(int schemaId)
        {
            var entities = mesDb.BinningPowers.AsNoTracking().Where(_ => _.SchemaId == schemaId && _.Valid).OrderBy(_ => _.Power).ToList();
            var models = Mapper.Map<List<VBinningPower>>(entities);
            var powerIds = models.Select(_ => _.PkId).Distinct().ToList();
            var currents = !powerIds.Any() ? new List<BinningCurrent>() : mesDb.BinningCurrents.AsNoTracking().Where(_ => powerIds.Contains(_.PowerId) && _.Valid).OrderBy(_ => _.CurrentMin).ToList();
            models.ForEach(power =>
            {
                power.Currents = Mapper.Map<List<VBinningCurrent>>(currents.Where(_ => _.PowerId == power.PkId).ToList());
            });

            return models;
        }

        /// <summary>
        /// 查询电流档列表
        /// </summary>
        /// <param name="powerId">功率档ID</param>
        /// <returns>电流档列表</returns>
        public List<VBinningCurrent> QueryBinningCurrents(int powerId)
        {
            var entities = mesDb.BinningCurrents.AsNoTracking().Where(_ => _.PowerId == powerId && _.Valid).OrderBy(_ => _.CurrentMin).ToList();
            var model = Mapper.Map<List<VBinningCurrent>>(entities);

            return model;
        }

        /// <summary>
        /// 获取电流档对象
        /// </summary>
        /// <param name="currentId">电流档ID</param>
        /// <returns>电流档对象</returns>
        public VBinningCurrent GetBinningCurrent(int currentId)
        {
            var entity = mesDb.BinningCurrents.AsNoTracking().FirstOrDefault(_ => _.PkId == currentId && _.Valid);
            return Mapper.Map<VBinningCurrent>(entity);
        }

        /// <summary>
        /// 编辑电流档
        /// </summary>
        /// <param name="model">电流档对象</param>
        public void EditCurrent(VBinningCurrent model)
        {
            var eixstCurrents = mesDb.BinningCurrents.AsNoTracking().Where(_ => _.PowerId == model.PowerId && _.Valid).ToList();
            eixstCurrents = model.PkId <= 0 ? eixstCurrents : eixstCurrents.Where(_ => _.PkId != model.PkId).ToList();
            if (eixstCurrents.Any(_ => string.Equals(_.LevelName, model.LevelName, StringComparison.CurrentCultureIgnoreCase)))
            {
                throw new MultiLanBizException(135008);//该电流档已存在
            }
            else if (eixstCurrents.Any(_ => model.CurrentMin >= _.CurrentMin && model.CurrentMin < _.CurrentMax
                                  || model.CurrentMax > _.CurrentMin && model.CurrentMax < _.CurrentMax
                                  || model.CurrentMin < _.CurrentMin && model.CurrentMax >= _.CurrentMax))
            {
                throw new MultiLanBizException(135009);//该电流判定范围跟现有电流档重合
            }

            if (model.PkId <= 0)
            {
                var power = mesDb.BinningPowers.FirstOrDefault(_ => _.PkId == model.PowerId && _.Valid);
                if (power == null)
                {
                    throw new MultiLanBizException(135007);//该功率档不存在
                }
                var entity = Mapper.Map<BinningCurrent>(model);
                entity.SchemaId = power.SchemaId;
                entity.CreateTime = DateTime.Now;
                mesDb.BinningCurrents.Add(entity);
            }
            else
            {
                var entity = mesDb.BinningCurrents.FirstOrDefault(_ => _.PkId == model.PkId && _.Valid);
                if (entity == null)
                {
                    throw new MultiLanBizException(135010);//该电流档不存在
                }

                mesDb.BinningCurrents.Attach(entity);
                entity.ModifyBy = model.ModifyBy;
                entity.ModifyTime = DateTime.Now;
                entity.LevelName = model.LevelName;
                entity.CurrentMin = model.CurrentMin;
                entity.CurrentMax = model.CurrentMax;
            }
            mesDb.SaveChanges();
        }

        /// <summary>
        /// 删除功率档
        /// </summary>
        /// <param name="model">功率档</param>
        public void DeletePower(VBinningPower model)
        {
            var entity = mesDb.BinningPowers.FirstOrDefault(_ => _.PkId == model.PkId && _.Valid);
            if (entity == null)
            {
                throw new MultiLanBizException(135007);//该功率档不存在
            }
            var workOrderSchemas = mesDb.WorkOrderBinningSchemas.AsNoTracking().Where(_ => _.BinningPowerId == entity.PkId && _.Valid).ToList();
            if (workOrderSchemas.Any())
            {
                throw new MultiLanBizException(135004, string.Join("、", workOrderSchemas.Select(_ => _.WorkOrderNo)));//分档规则已在工单使用，无法删除
            }

            mesDb.BinningPowers.Attach(entity);
            entity.Valid = false;
            entity.ModifyBy = model.ModifyBy;
            entity.ModifyTime = DateTime.Now;
            mesDb.SaveChanges();
        }

        /// <summary>
        /// 删除电流档
        /// </summary>
        /// <param name="model">电流档</param>
        public void DeleteCurrent(VBinningCurrent model)
        {
            var entity = mesDb.BinningCurrents.FirstOrDefault(_ => _.PkId == model.PkId && _.Valid);
            if (entity == null)
            {
                throw new MultiLanBizException(135010);//该电流档不存在
            }
            //var workOrderSchemas = mesDb.WorkOrderBinningSchemas.AsNoTracking().Count(_ => _.BinningSchemeId == model.SchemaId && _.Valid);
            //if (workOrderSchemas > 0)
            //{
            //    throw new MultiLanBizException(135004);//分档规则已在工单使用，无法删除
            //}

            mesDb.BinningCurrents.Attach(entity);
            entity.Valid = false;
            entity.ModifyBy = model.ModifyBy;
            entity.ModifyTime = DateTime.Now;
            mesDb.SaveChanges();
        }

        /// <summary>
        /// 获取工单分档规则
        /// </summary>
        /// <param name="orderNo">订单号</param>
        /// <param name="workOrderNo">工单号</param>
        /// <returns>工单分档规则</returns>
        public VWorkOrderBinningSchema GetWorkorderBinningSchema(string orderNo, string workOrderNo)
        {
            WorkOrderBinningSchema entity = null;
            if (!string.IsNullOrWhiteSpace(workOrderNo))
            {
                entity = mesDb.WorkOrderBinningSchemas.AsNoTracking().FirstOrDefault(_ => _.WorkOrderNo == workOrderNo && _.Valid);
            }
            else if (!string.IsNullOrWhiteSpace(orderNo))
            {
                entity = mesDb.WorkOrderBinningSchemas.AsNoTracking().FirstOrDefault(_ => _.OrderNo == orderNo && _.WorkOrderNo == "" && _.Valid);
            }

            return Mapper.Map<VWorkOrderBinningSchema>(entity);
        }

        /// <summary>
        /// 获取工单分档规则
        /// </summary>
        /// <param name="orderNo">订单号</param>
        /// <param name="workOrderNo">工单号</param>
        /// <returns>工单分档规则</returns>
        public void SaveWorkorderBinningSchema(VWorkOrderBinningSchema model)
        {
            if (model.BinningSchemeId <= 0)
            {
                throw new MultiLanBizException(135011);//工单分档规则不合法
            }
            var schema = mesDb.BinningSchemas.FirstOrDefault(_ => _.PkId == model.BinningSchemeId && _.Valid);
            if (schema == null)
            {
                throw new MultiLanBizException(135013);//分档规则不存在
            }
            var powers = mesDb.BinningPowers.Where(_ => _.SchemaId == model.BinningSchemeId && _.Valid).ToList();
            var currents = mesDb.BinningCurrents.Where(_ => _.SchemaId == model.BinningSchemeId && _.Valid).ToList();
            if (!powers.Any() || powers.Any(_ => !currents.Any(c => c.PowerId == _.PkId)))
            {
                throw new MultiLanBizException(135012);//当前分档规则不可用，请保证至少有一个功率档，并且每个功率档至少有一个电流档
            }
            var entities = mesDb.WorkOrderBinningSchemas.Where(_ => _.OrderNo == model.OrderNo && _.WorkOrderNo == model.WorkOrderNo && _.Valid).ToList();
            foreach (var item in entities)
            {
                item.Valid = false;
                item.ModifyBy = model.CreateBy;
                item.ModifyTime = DateTime.Now;
            }

            model.CreateTime = DateTime.Now;
            var entity = Mapper.Map<WorkOrderBinningSchema>(model);
            mesDb.WorkOrderBinningSchemas.Add(entity);
            mesDb.SaveChanges();
        }
    }
}
